<!DOCTYPE html>
<html lang="en" xmlns:zxw="http://www.w3school.com.cn" xmlns:njzxw="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>首页</title>
    <link rel="stylesheet" href="../../js/common/layui/css/layui.css">
    <link rel="stylesheet" href="../../css/common/animate.css" />
    <link rel="stylesheet" href="../../css/common/common.css" />
    <link rel="stylesheet" href="../../css/common/map.css" />
</head>
<body class="layout-zxw layout-zxw-add" >
    <form action="" id="shopInfoform" class="layui-form layui-fluid" lay-filter="shopInfofilter" >
        <div class="layui-row">
            <zxw:signUpload id="shop_pic" drag="true" parcelName="商铺照片" url=""></zxw:signUpload>
            <!--<zxw:input id="shop_pic" type="text" parcel="true" placeholder="请输入商铺照片" parcelName="商铺照片" parcelclass="col-xs-12" inline="false" value="" maxlength="50" name="shop_pic" lay_verify="" class="" ></zxw:input>-->
        </div>
        <div class="layui-row">
            <zxw:input id="shop_name" type="text" parcel="true" placeholder="请输入商铺名称" parcelName="商铺名称" parcelclass="col-xs-12" inline="false" value="" maxlength="50" name="shop_name" lay_verify="required" class="" ></zxw:input>
        </div>
        <div class="layui-row">
            <zxw:input id="shop_name" type="text" parcel="true" placeholder="请输入商铺联系电话" parcelName="联系电话" parcelclass="col-xs-12" inline="false" value="" maxlength="50" name="shop_tel"
                       lay_verify="required" class="" ></zxw:input>
        </div>
        <div class="layui-row">
            <zxw:inputTime id="shop_mor" type="time" range="true" format="HH:mm" parcel="true" placeholder="商铺早班开始时间" parcelName="早班开始时间" parcelclass="col-xs-6"
                       inline="false" value="" maxlength="50"
                       name="shop_mor" lay_verify="required" ></zxw:inputTime>
        </div>
        <div class="layui-row">
            <zxw:inputTime id="shop_after" range="true" type="time" format="HH:mm" parcel="true" placeholder="商铺晚班开始时间"
                       parcelName="晚班开始时间" parcelclass="col-xs-6" inline="false" value="" maxlength="50"
                           name="shop_after" lay_verify="required" ></zxw:inputTime>
        </div>

        <div class="layui-row">
            <zxw:select parcel="true" parcelName="所在地" id="shop_district" url="MY_URL.SHOPINFO.GETCITY"
                        multiple="true" name="shop_district" field_name_key="name" field_value_key="id"></zxw:select>
        </div>
        <div class="layui-row">
            <label class="layui-form-label">选择地址:</label>
            <div class="layui-input-block">
                <div style="width: 500px;height: 500px;position: relative;">
                    <div id="mapContainer"></div>
                    <div id="tip">
                        <b>请输入关键字：</b>
                        <input type="text" id="keyword" name="keyword" value="" onkeydown='shopInfo.keydown(event)' style="width: 95%;"/>
                        <div id="result1" name="result1"></div>
                    </div>
                    <div id="pos">
                        <b>鼠标左键在地图上单击获取坐标</b>
                        <div style="display: none">X：<input type="text" id="lngX" name="lngX" value=""/> Y：<input type="text" id="latY" name="latY" value=""/></div>
                        <!--<div>城市：<input type="text" id="city" width="210px" name="city" value=""/></div>-->
                    </div>
                </div>
            </div>
        </div>
        </div>
        <div class="layui-row">
            <zxw:input id="shop_address" type="text" parcel="true" placeholder="请输入店铺详细地址" parcelName="店铺详细地址" parcelclass="col-xs-12" inline="false" value="" maxlength="50" name="shop_address" lay_verify="required" class="" ></zxw:input>
        </div>
        <div class="layui-row">
            <zxw:input id="shop_long" type="text" parcel="true" placeholder="请输入经度" parcelName="经度" parcelclass="col-xs-3"
                       inline="true" value="" maxlength="50" name="shop_long"
                       lay_verify="required" class="" readonly="readonly" ></zxw:input>
            <zxw:input id="shop_lat" type="text" parcel="true" placeholder="请输入维度" parcelName="维度" parcelclass="col-xs-3"
                       inline="true" value="" maxlength="50" name="shop_lat"
                       lay_verify="required" class="" readonly="readonly"></zxw:input>
            <zxw:input id="shop_orderby" type="text" parcel="true" remark="门店在微信端门店列表的显示顺序，越小越靠前" placeholder="店在微信端门店列表的显示顺序" parcelName="商铺顺序" parcelclass="col-xs-3" inline="true"
                       value="" maxlength="3"
                       name="shop_orderby" lay_verify="required|number" class="" ></zxw:input>
        </div>
        <div class="layui-row">
            <zxw:radio id="shop_status" fun="" parcel="true" checked="1" field_value_key="values" field_name_key="name" isItem="true" url="SHOP.STATE" lay_verify="required" parcelName="商铺状态"
                       parcelclass="col-xs-12"
                       inline="false"></zxw:radio>
        </div>
        <div class="layui-row">
            <zxw:textarea rich="true" id="shop_desc" type="text" parcel="true" placeholder="请输入商铺介绍"
                    parcelName="商铺介绍" parcelclass="col-xs-12" inline="false" value="" maxlength="50" name="shop_desc"
                           lay_verify=""
                  class="" />
        </div>
    </form>


    <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=ac5cbe415bae33b77a1703e7ce276695"></script>
    <script type="application/javascript" src="../../js/common/own/own.js?layui,jquery,njzxw,URL,myurl,myconfig,shopInfo" >
        shopInfo.init();
        njzxw.layui.val({
            url:MY_URL.SHOPINFO.QUERYID,
            gather: ['shop_district'],
            paramExe:function(data){
                //存在初始化需要额外处理的在此操作
                data.shop_district0=data.shop_province;
                data.shop_district1=data.shop_city;
                data.shop_district2=data.shop_district;
                data.shop_after =data['shop_after_start']+" - "+data['shop_after_end'];
                data.shop_mor =data['shop_mor_start']+" - "+data['shop_mor_end'];
                console.log('========',data);
                console.log(typeof(data.shop_long))
                if(typeof(data.shop_long) == "string" && typeof(data.shop_lat) == "object") {
                    shopInfo.addMarkerOnMap([data.shop_long,data.shop_lat])
                    shopInfo.mapObj.setFitView();
                }

                return data;
            }
        });
        njzxw.layui.submit({
            url:MY_URL.SHOPINFO.SAVE,
            againparams: true,
            prepFun: function (data) {
                var cnt = $("select[id^='shop_district']").size();
                var supper_id1 = data['shop_district' + (cnt - 1)];
                var supper_id2 = data['shop_district' + (cnt - 2)];
                data['shop_district'] = (supper_id1 == '' ? ((supper_id2 != '' && supper_id2 != undefined) ? supper_id2 : supper_id1) : supper_id1);
                data['shop_after_start']= $.trim(data['shop_after'].split("-")[0].trim())
                data['shop_after_end']= $.trim(data['shop_after'].split("-")[0].trim())
                data['shop_mor_start']= $.trim(data['shop_mor'].split("-")[0].trim())
                data['shop_mor_end']= $.trim(data['shop_mor'].split("-")[0].trim())
                return data;
            }
        });
    </script>
</body>
</html>